﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CtefCrmImport.Common.Extensions
{
    public static class CrmErrorExtensions
    {
        public static string Format(this IEnumerable<CrmError> errors)
        {
            if (errors.IsNullOrEmpty())
            {
                return string.Empty;
            }

            var buffer = new StringBuilder();
            foreach (var e in errors)
            {
                buffer.AppendFormat("{0}: {1}", e.Field, e.Message);
                buffer.AppendLine();
            }

            return buffer.ToString();
        }
    }
}
